<?php
namespace app\admin\controller;

use think\Exception;

class Certification extends Common
{
    private $obj;
    public function _initialize()
    {
        parent::_initialize();
        $this->obj = model('certification');
    }

    public function index()
    {
        $param = input('param.');
        $this->assign('param', $param);
        $where = [];
        if (input('?param.status') && input('param.status') > 0) {
            $where['status'] = input('param.status');
        }

        if (input('?param.mobile') && input('param.mobile') > 0) {
            $member = model('member')->get(['username' => input('param.mobile')]);
            $where['member_id'] = $member->id;
        }

        $data = $this->obj->where($where)->paginate('25', false, ['query' => $param]);
        //echo $this->obj->getLastSql(); exit;
        $this->assign('data', $data);
        return view();
    }

    public function audit() {
        $value = input('param.value');
        $id = input('param.id');
        $audit_msg = input('param.audit_msg', '');
        $this->obj->save(['status' => $value, 'audit_msg' => $audit_msg], ['id' => $id]);
        $this->success('审核成功！');
    }
}
